/*
 * Copyright (c) 2010, VeRSI Consortium
 *   (Victorian eResearch Strategic Initiative, Australia)
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the VeRSI, the VeRSI Consortium members, nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package versi.vitro.oaiserviceprovider.service.jena.api;

import java.io.ByteArrayOutputStream;

import com.hp.hpl.jena.rdf.model.ModelMaker;

/**
 * Service for managing Jena.
 */
public interface JenaService {

    /**
     * Creates a model.
     * 
     * @param modelName
     *            Name of the model to be created.
     * 
     */
    void createModel(final String modelName);

    /**
     * Deletes a model.
     * 
     * @param modelName
     *            Name of the model to be deleted.
     * 
     */
    void deleteModel(final String modelName);

    /**
     * Subtracts one model from other model and stores the result in the result
     * model.
     * 
     * @param subtractedFromModel
     * @param subtractedByModel
     * @param resultModel
     *            Result model.
     */
    void subtractModels(final String subtractedFromModel, final String subtractedByModel, final String resultModel);

    /**
     * Clears the context of a model.
     * 
     * @param modelName
     *            Name of the model to be cleared the content.
     * 
     */
    void clearModel(final String modelName);

    /**
     * Removes a model.
     * 
     * @param modelName
     *            Name of the model to be removed.
     * 
     */
    void removeModel(final String modelName);

    /**
     * Renames a blank node from source models and populate to destination model
     * .
     * 
     * @param namespaceEtcStr
     *            Namespace.
     * @param sourceModels
     *            Names of the model as source.
     * @param destModel
     *            Name of the destination model.
     * 
     * 
     */
  //  void renameBlankNode(final String namespaceEtcStr, final String[] sourceModels, final String destModel);

    /**
     * Gets a model content as a byteArray.
     * 
     * @param modelName
     *            Model Name.
     * @param lang
     *            Model export format.
     * @return ByteArrayOutputStream Byte Array representation of a model.
     * 
     */
    ByteArrayOutputStream getModelAsOutputStream(final String modelName, final String lang);

    /**
     * Executes SPARQL CONSTRUCT Query.
     * 
     * @param sparql
     *            SPARQL construct statement for creating a model.
     * @param sourceModels
     *            source models's name.
     * @param destModel
     *            destination model name.
     * @param useDefaultSource
     * 
     */
    void populateModelwithSPARQL(final String sparql, final String[] sourceModels, final String destModel,
	    final boolean useDefaultSource);

    /**
     * Executes a sparql query.
     * 
     * @param sparql
     *            A SPARQL statement.
     * @param sourceModels
     *            source models.
     * 
     * @return result of the sparql query
     */
    byte[] executeSparqlQuery(final String sparql, final String sourceModels);

    /**
     * Sets the modelMaker.
     * 
     * @param modelMaker
     *            to set.
     */
    void setModelMaker(final ModelMaker modelMaker);

    /**
     * Gets Jena Model Maker.
     * 
     * @return ModelMaker Jena Model Maker.
     */
    ModelMaker getModelMaker();

    /**
     * Gets Jena Service Helper.
     * 
     * @return JenaHelper Jena Service Helper
     */
    JenaHelper getJenaHelper();

    /**
     * Adds a RDF relationship within a model.
     * 
     * @param modelName
     *            Model Name
     * @param subject
     *            Subject of RDF relationship.
     * @param predicate
     *            Predicate of RDF relationship.
     * @param object
     *            Object of RDF relationship.
     * 
     */
    void addRDF(final String modelName, final String subject, final String predicate, final String object);

    /**
     * Removes a RDF relationship within a model.
     * 
     * @param modelName
     * @param subject
     * @param predicate
     * @param object
     */
    void removeRDF(final String modelName, final String subject, final String predicate, final String object);

    /*    *//**
     * Get a RDF relationship from a model.
     * 
     * @param modelName
     *            Model Name
     * @param subject
     *            Subject of RDF relationship.
     * @param predicate
     *            Predicate of RDF relationship.
     * @param object
     *            Object of RDF relationship.
     * @param String
     *            [] RDF representation.
     * 
     */
    /*
     * String[] getRDF(final String modelName, final String subject, final
     * String predicate, final String object);
     */

    /**
     * Deletes a RDF relationship from a model.
     * 
     * @param modelName
     *            Model Name
     * @param subject
     *            Subject of RDF relationship.
     * @param predicate
     *            Predicate of RDF relationship.
     * @param object
     *            Object of RDF relationship.
     * 
     */
    void deleteRDF(final String modelName, final String subject, final String predicate, final String object);

    /**
     * Prints all model and its model sizes in the log file.
     */
    void printAllModelsSize();

}
